package com.definity.toolkit.web.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.definity.toolkit.web.servlet.CaptchaServlet;

public class CaptchaUtils {

	private CaptchaUtils() {
		
	}
	
	public static boolean check(HttpServletRequest request, String captcha) {
		HttpSession session = request.getSession(true);
		Object currentCaptcha = session.getAttribute(CaptchaServlet.CAPTCHA_TEXT);
		session.removeAttribute(CaptchaServlet.CAPTCHA_TEXT);
		
		return !currentCaptcha.equals(captcha);
	}
	
}
